package com.company.test16;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Time;

/**
 * Created by Administrator on 2016.8.2.
 */
public class Test16_12 extends JFrame{
    private StillClock clock=new StillClock();
    public Test16_12(){
        add(clock);

        Timer timer=new Timer(1000,new TimerListener());
        timer.start();
    }

    public static void main(String args[]){
        JFrame frame=new Test16_12();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setTitle("Welcome to JAVA");
        frame.setVisible(true);
    }

    private class TimerListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            clock.setCurrentTime();
            clock.repaint();
        }
    }
}
